'use strict';

/**
 * 图片压缩处理
 */

const sharp = require('sharp');

function resize(buffer, width, height) {
    if (height) {
        return sharp(buffer).resize(width, height).toBuffer();
    } else {
        return sharp(buffer).resize(width).toBuffer();
    }
}

exports.resize = resize;
